# !/usr/bin/env python
# -*- coding: utf-8 -*-

from wechatpy.client import WeChatClient
from wechatpy.client.api import WeChatMedia
from wechatpy.client.api import WeChatMenu, WeChatMessage, WeChatGroup
from wechatpy.client.api import WeChatQRCode
from wechatpy.client.api import WeChatSemantic
from wechatpy.client.api.jsapi import WeChatJSAPI

from base.const import CacheKey

_cache_key = CacheKey()


class Client(WeChatClient):
    """
    基本Client
    """

    def __init__(self, appid=None, secret=None, access_token=None, session=None):
        super(Client, self).__init__(appid=appid, secret=secret, access_token=access_token, session=session)

    def __repr__(self):
        return '<Client(appid=%s, secret=%s, access_token=%s)>' % (self.appid, self.secret, self.access_token)


class Menu(WeChatMenu):
    """
    自定义菜单
    """

    def __init__(self, client=None, appid=None, secret=None, access_token=None, session=None):
        if client is None:
            client = Client(appid, secret, access_token, session)
        super(WeChatMenu, self).__init__(client)


class QRCode(WeChatQRCode):
    """
    二维码
    """

    def __init__(self, client=None, appid=None, secret=None, access_token=None, session=None):
        if client is None:
            client = Client(appid, secret, access_token, session)
        super(QRCode, self).__init__(client)


class Semantic(WeChatSemantic):
    """
    语义理解
    """

    def __init__(self, client=None, appid=None, secret=None, access_token=None, session=None):
        if client is None:
            client = Client(appid, secret, access_token, session)
        super(Semantic, self).__init__(client)


class Media(WeChatMedia):
    """
    媒体文件
    """

    def __init__(self, client=None, appid=None, secret=None, access_token=None, session=None):
        if client is None:
            client = Client(appid, secret, access_token, session)
        super(Media, self).__init__(client)


class JsAPI(WeChatJSAPI):
    """
    JsAPI
    """

    def __init__(self, client=None, appid=None, secret=None, access_token=None, session=None):
        if client is None:
            client = Client(appid, secret, access_token, session)
        super(JsAPI, self).__init__(client)

    def __repr__(self):
        return '<Client(access_token=%s)>' % self.access_token


class Message(WeChatMessage):
    """
    自定义消息
    """

    def __init__(self, client=None, appid=None, secret=None, access_token=None, session=None):
        if client is None:
            client = Client(appid, secret, access_token, session)
        super(Message, self).__init__(client)


class Group(WeChatGroup):
    """
    自定义分组
    """

    def __init__(self, client=None, appid=None, secret=None, access_token=None, session=None):
        if client is None:
            client = Client(appid, secret, access_token, session)
        super(Group, self).__init__(client)
